package com.gmadmin.configuration.secutity;

import com.gmadmin.common.HttpStatus;
import com.gmadmin.utils.ResponseUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.access.AccessDeniedHandler;

/**
 * @author zhangliang
 * @version 1.0
 * Security 结果处理配置，统一返回权限不足
 * @date 2021/1/25 15:14
 */
@Configuration
public class SecurityHandlerConfig {

    @Bean
    public AccessDeniedHandler accessDeniedHandler(){
        return ((httpServletRequest, httpServletResponse, e) -> ResponseUtil.renderJson(httpServletResponse, HttpStatus.UNAUTHORIZED,null));
    }
}
